package objectdiagrameditor.features.object;



import objectdiagrameditor.util.Loader;

import org.eclipse.graphiti.features.ICreateFeature;
import org.eclipse.graphiti.features.IFeatureProvider;
import org.eclipse.graphiti.features.context.ICreateContext;
import org.eclipse.graphiti.features.impl.AbstractCreateFeature;
import org.eclipse.graphiti.mm.pictograms.Diagram;

import fUML.Semantics.Classes.Kernel.KernelFactory;

public class CreateObjectFeature extends AbstractCreateFeature implements
		ICreateFeature {

	public CreateObjectFeature(IFeatureProvider fp) {
		super(fp, "Object", "Creates a new Object");
	}

	@Override
	public boolean canCreate(ICreateContext context) {
		return context.getTargetContainer() instanceof Diagram;
	}

	@Override
	public Object[] create(ICreateContext context) {
		// TODO: create the domain object here
		fUML.Semantics.Classes.Kernel.Object newDomainObject = null;
		
		newDomainObject = (fUML.Semantics.Classes.Kernel.Object) KernelFactory.eINSTANCE.createObject();
		Loader.getResource("C:\\eclipse_workspace\\graphiti-objecteditor-fuml\\fuml\\model\\TestPackage.xmi");
		//getDiagram().eResource().getContents().add(newDomainObject);
		//addGraphicalRepresentation(context, newDomainObject);
		return new Object[] { newDomainObject };
	}
}
